package com.module.dialog;

import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

/**
 * 消息对话框
 * Created by dell on 2018/7/5
 */

public class MessageDialog extends BaseBuilder<MessageDialog> implements View.OnClickListener {

    TextView tvMessage; //消息控件
    MessageParam mMessageParam; //消息参数

    public MessageDialog(Context context) {
        super(context);
    }

    @Override
    public MessageDialog getBuilder() {
        return this;
    }

    /**
     * 初始化控件
     */
    @Override
    public void initContentView() {
        mMessageParam = new MessageParam();
        View contentView = LayoutInflater.from(mContext).inflate(R.layout.dialog_message, null);
        tvMessage = contentView.findViewById(R.id.message);
        setContentView(contentView);
    }

    @Override
    protected void connectView() {
        if (TextUtils.isEmpty(mMessageParam.message)) {
            tvMessage.setVisibility(View.GONE);
        } else {
            tvMessage.setVisibility(View.VISIBLE);
            tvMessage.setText(mMessageParam.message);
        }
    }


    public MessageDialog setMessage(String message) {
        mMessageParam.message = message;
        return this;
    }


    /**
     * 消息参数
     */
    class MessageParam {
        String message;
    }
}